#include<bits/stdc++.h>
using namespace std;
struct node
{
    int l, r;
    bool operator<(const node &t) const
    {
        return r < t.r;
    }
};
int T, n, m, L, V, d[100005], v[100005], a[100005], p[100005];
vector<int> v1;
vector<node> v2;
int findp(int x)
{
    int l = 1, r = m, res = 0;
    while(l <= r)
    {
        int mid = l + r >> 1;
        if(p[mid] == x)
            return mid;
        if(p[mid] < x)
            res = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    return res;
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        v1.clear();
        v2.clear();
        int ans = 0;
        for(int i = 1; i <= n; i++)
            scanf("%d%d%d", d + i, v + i, a + i);
        for(int i = 1; i <= m; i++)
            scanf("%d", p + i);
        int t = -1;
        for(int i = 1; i <= n; i++)
            if(a[i] >= 0 && d[i] <= p[m] && v[i] * v[i] + 2 * a[i] * (p[m] - d[i]) > V * V)
            {
                ans++;
                if(v[i] > V)
                    t = max(t, d[i]);
                else
                    t = max(t, (V * V - v[i] * v[i]) / (2 * a[i]) + d[i] + 1);
            }
            else if(a[i] < 0 && v[i] > V && d[i] <= p[m])
            {
                int x = min(p[m], (int)ceil(1.0 * (V * V - v[i] * v[i]) / (2 * a[i])) + d[i] - 1);
                int idx = lower_bound(p + 1, p + 1 + m, d[i]) - p;
                if(x >= p[idx])
                {
                    ans++;
                    v2.push_back({d[i], x});
                }
            }
        sort(v2.begin(), v2.end());
        for(int i = 0; i < v2.size(); i++)
            if(!v1.size() || !(p[v1.back()] >= v2[i].l && p[v1.back()] <= v2[i].r))
                v1.push_back(findp(v2[i].r));
        if(~t)
        {
            int idx = lower_bound(p + 1, p + 1 + m, t) - p;
            if(!v1.size() || v1.back() < idx)
                v1.push_back(idx);
        }
        printf("%d %d\n", ans, m - v1.size());
    }
    return 0;
}
